package com.cloud_disk.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 作者：郑雨蒙
 * 日期：2021/12/23 16:08
 */
@Configuration
public class FileConfig implements WebMvcConfigurer {
    //上传地址
    @Value("${file.upload.path}")
    private  String filePath;

    //相对地址
    @Value("${file.upload.relative}")
    private  String fileRelativePath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry){
        registry.addResourceHandler(fileRelativePath).addResourceLocations("file:/"+filePath);
    }
}
